package com.etms.config;


import com.etms.Interceptor.LoginInterceptor;
import com.etms.Interceptor.OrderInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;
import java.util.List;

@Configuration
public class MvcConfig implements WebMvcConfigurer {


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登录start..
        LoginInterceptor loginInterceptor=new LoginInterceptor();
        List<String>patterns=new ArrayList<>();
        patterns.add("/bootstrap3/**");
        patterns.add("/css/**");
        patterns.add("/images/**");
        patterns.add("/js/**");
        patterns.add("/login.html");
        patterns.add("/users/login");

        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")
                .excludePathPatterns(patterns);
        //登录end...

        //权限start..
//        OrderInterceptor orderInterceptor=new OrderInterceptor();//权限拦截器
//        List<String>orderPatterns=new ArrayList<>();
//        orderPatterns.add("/index.html");
//        orderPatterns.add("/g_ruku.html");
//        orderPatterns.add("/g_chuku.html");
//        orderPatterns.add("/g_huopin.html");
//        orderPatterns.add("/bootstrap3/**");
//        orderPatterns.add("/css/**");
//        orderPatterns.add("/images/**");
//        orderPatterns.add("/js/**");
//        orderPatterns.add("/login.html");
//        registry.addInterceptor(orderInterceptor)
//                .excludePathPatterns(orderPatterns)
//                .addPathPatterns("/**");

    }
}
